﻿using UnityEngine;

namespace DL.Health
{
    /// <summary>
    /// 角色生命值数据
    /// </summary>
    [System.Serializable]
    public class CharacterHealthData
    {
        private float _currentHP;
        private float _currentStrenth;
        private float _maxHP;
        private float _maxStrenth;
        private bool _isDead => (_currentHP <= 0);

        public float CurrentHP => _currentHP;
        public float CurrentStrenth => _currentStrenth;
        public float MaxHP => _maxHP;
        public float MaxStrenth => _maxStrenth;
        public bool IsDead => _isDead;

        public CharacterHealthData(float maxHp, float maxStrenth)
        {
            _maxHP = maxHp;
            _maxStrenth = maxStrenth;
            _currentHP = _maxHP;
            _currentStrenth = _maxStrenth;
        }


        /// <summary>
        /// 受到伤害
        /// </summary>
        public void ChangeForHp(float val)
        {
            _currentHP = Mathf.Clamp(_currentHP + val, 0f, _maxHP);//否则扣除生命值
        }

        public void ChangeForStrenth(float val)
        {
            _currentStrenth = Mathf.Clamp(_currentStrenth + val, 0f, _maxStrenth);
        }

        public void Reset()
        {
            _currentHP = _maxHP;
            _currentStrenth = _maxStrenth;
        }
    }
}